public class QueryUserInfoServlet extends HttpServlet{
	private BllFactory bllFactory = BllFactory.getBllFactory();

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset = utf-8");
		
		int type = Integer.parseInt(request.getParameter("type"));
		String name = "";
		String idcard = "";
		int roomid = 0;
		if(type==1){
			 name = new String(request.getParameter("content").getBytes("ISO-8859-1"),"utf-8");
		}
		else if(type==2){
	         idcard = new String(request.getParameter("content").getBytes("ISO-8859-1"),"utf-8");
		}
		else{
			 roomid = Integer.parseInt(request.getParameter("content"));
		}
		BLLUser bllUser = bllFactory.getInstance(BLLUser.class);
		if(type == 1){
			Map<String, Object> map = bllUser.queryUser(name);
			JSONObject json = JSONObject.fromObject(map);
			System.out.println("!!!!!!!!"+json);
			PrintWriter pw = response.getWriter();
			pw.print(json);
			pw.close();
		}else if (type == 2) {
			Map<String, Object> map = bllUser.queryUserByIdcard(idcard);
			JSONObject json = JSONObject.fromObject(map);
			
			PrintWriter pw = response.getWriter();
			pw.print(json);
			pw.close();
		}else {
			BLLRoom_user bllRoomUser = bllFactory.getInstance(BLLRoom_user.class);
			Map<String, Object> map = bllRoomUser.queryUserByRoomid(roomid);
			JSONObject json = JSONObject.fromObject(map);
			
			PrintWriter pw = response.getWriter();
			pw.print(json);
			pw.close();
		}
	}
	
	
}